import { getuserApi } from '../../request/api'
export default {
  namespaced: true,
  state: {
    cartTotal: 0,
    userInfo: {
      headImg: require('../../assets/img/service.848ec511.png'),
      nickName: '小李子',
      coin: 200
    },
  },
  mutations: {
    changuserInfo(state, payload) {
      state.cartTotal = payload.cartTotal;
      state.userInfo = payload.userInfo
    },
    // 初始化数据
    inituserInfo(state) {
      state.cartTotal = 0;
      state.userInfo = {
        headImg: require('../../assets/img/service.848ec511.png'),
        nickName: '小李子',
        coin: 200
      }
    }
  },
  actions: {
    async asyncchanguserInfo(context, payload) {
      let res = await getuserApi();
      context.commit('changuserInfo', res.data)
    }
  }
}